<template>
  <section>
    <!--工具条-->
    <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
      <el-form :inline="true" :model="filters">
        <!--    <el-form-item label="注册日期">
            <el-date-picker v-model="filters.date" type="daterange" placeholder="选择日期范围" style="width:100%;"></el-date-picker>
          </el-form-item> -->
        <el-row :gutter="40">
          <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
            <el-input size="small" style="width:100%;" v-model.trim="filters.id" placeholder="客户编码"></el-input>
          </el-col>
          <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
            <el-input size="small" style="width:100%;" v-model.trim="filters.userName" placeholder="真实姓名"></el-input>
          </el-col>
          <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
            <el-input size="small" style="width:100%;" v-model.trim="filters.nickName" placeholder="昵称"></el-input>
          </el-col>
          <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
            <el-input size="small" style="width:100%;" v-model.trim="filters.agrementNo" placeholder="业务关系代码"></el-input>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
            <!-- <el-input size="small" style="width:100%;" v-model.trim="filters.Minpoints"  placeholder="最小积分余额"></el-input> -->
            <el-date-picker size="small" style="width:100%;" type="date" placeholder="注册起日期" v-model="filters.signStartTime"></el-date-picker>
          </el-col>
          <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
            <!-- <el-input size="small" style="width:100%;" v-model.trim="filters.Maxpoints"  placeholder="最大积分余额"></el-input> -->
            <el-date-picker size="small" style="width:100%;" type="date" placeholder="注册止日期" v-model="filters.signEndTime"></el-date-picker>
          </el-col>
          <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
            <el-tooltip class="item" effect="dark" content="是否店主" placement="top">
              <el-select style="width:100%;" clearable v-model="filters.storeFlag" size="small" placeholder="是否店主">
                <!-- <el-option label="全部" value="-1"></el-option> -->
                <el-option label="是" value="1"></el-option>
                <el-option label="否" value="0"></el-option>
              </el-select>
            </el-tooltip>
          </el-col>
          <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
            <el-select style="width:100%;" clearable v-model="filters.userType" size="small" placeholder="店主类别">
              <!-- <el-option label="全部店主类别" value="-1"></el-option> -->
              <el-option label="游客" value="1"></el-option>
              <el-option label="普通客户" value="2"></el-option>
              <el-option label="专业代理" value="3"></el-option>
              <el-option label="商户" value="4"></el-option>
              <el-option label="销售人员" value="5"></el-option>
            </el-select>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
            <el-select size="small" clearable style="width:100%;" v-model="filters.branchCode" placeholder="分公司">
              <!-- <el-option  label="全部公司"  value="-1"  ></el-option> -->
              <el-option v-for="(item,index) in filters.items" :key="index" :label="item.codeCname" :value="item.code"></el-option>
            </el-select>
          </el-col>
          <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
            <el-input size="small" style="width:100%;" v-model.trim="filters.mobile" placeholder="手机号码"></el-input>
          </el-col>
          <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
            <!-- <el-input size="small" style="width:100%;" v-model.trim="filters.Maxpoints"  placeholder="最大积分余额"></el-input> -->
            <el-tooltip class="item" effect="dark" content="开店时间" placement="top">
                <el-date-picker size="small" style="width:100%;"  v-model.trim="filters.storeCreateTime" type="daterange" align="left" :picker-options="pickerOptions0" placeholder="请选择开店时间范围">
                </el-date-picker>
            </el-tooltip>
          </el-col>
          <!-- <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-bottom:5px;">
            <el-select size="small" clearable  style="width:100%;"  v-model.trim="filters.userType" placeholder="客户单位类型">
                <el-option label="支付失败"  value="0"></el-option>
                <el-option label="已支付"  value="1"></el-option>
                <el-option label="未支付"  value="2"></el-option>
                <el-option label="无效"  value="3"></el-option>
            </el-select>
          </el-col> -->
          <!-- <el-col :xs="6" :sm="4" :md="3" :lg="2"style="margin-bottom:5px;"> -->
          <el-form-item style="float:right;margin-right:20px;">
            <el-button size="small" icon="upload2" type="primary" @click="exportExcels" v-show="customExport">导出</el-button>
          </el-form-item>
          <el-form-item style="float:right;">
            <el-button size="small" type="primary" :disabled="configUser()" icon="plus" v-show="customAdd" @click="handleAdd">新增</el-button>
          </el-form-item>
          <!-- </el-col> -->
          <el-form-item style="float:right;">
            <el-button size="small" type="primary" v-show='customBatchAdd' :disabled="configUser()" v-on:click="batchaccount">开户</el-button>
          </el-form-item>
          <!-- <el-col :xs="6" :sm="4" :md="3" :lg="2"style="margin-bottom:5px;"> -->
          <el-form-item style="float:right;">
            <el-button size="small" icon="search" type="primary" v-on:click="getcustoms(true)" v-show="customQuery">查询</el-button>
          </el-form-item>
          <!-- </el-col> -->

        </el-row>

      </el-form>
    </el-col>

    <!--列表-->
    <el-table :data="customs" stripe border :height="winHeight-274" highlight-current-row v-loading="listLoading" @select-all="selsAll" @selection-change="selsChange" @select="selectTure" style="width: 100%;" ref="table">
      <el-table-column type="selection" :reserve-selection="true" width="55" :selectable="selectables">
      </el-table-column>
      <el-table-column prop="userName" align="center" label="真实姓名" width="100" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="nickName" align="center" label="昵称" min-width="120" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="storeFlag" align="center" label="是否店主" min-width="100" :formatter="formatStoreFlag">
      </el-table-column>
      <el-table-column prop="agrementNo" align="center" label="业务关系代码" min-width="130">
      </el-table-column>
      <el-table-column prop="mobile" align="center" label="手机号" min-width="125">
      </el-table-column>
      <el-table-column prop="email" align="center" label="电子邮箱" min-width="120" sortable show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="channelName" align="center" label="销售渠道名称" min-width="130" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="channelCode" align="center" label="销售渠道编码" min-width="130" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="saleName" align="center" label="销售人姓名" min-width="130" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="saleCode" align="center" label="销售人编码" min-width="130" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="refereeId" align="center" label="介绍人ID" min-width="100">
      </el-table-column>
      <el-table-column prop="userCode" align="center" label="客户编码" min-width="125">
      </el-table-column>
      <el-table-column prop="password" align="center" label="密码" min-width="100" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="level" align="center" label="等级" min-width="80">
      </el-table-column>
      <el-table-column prop="popularity" align="center" label="人气" min-width="80" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="branchCode" align="center" label="分公司编码" min-width="110">
      </el-table-column>
      <el-table-column prop="registeDate" align="center" label="注册时间" min-width="120" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="lastloginDate" align="center" label="上次登陆时间" min-width="130" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="shippingAddress" align="center" label="配送地址" min-width="120" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="areaName" align="center" label="常驻地区" min-width="120" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="customName" label="客户单位名称" min-width="120" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="channelType" label="客户单位类型" min-width="120" show-overflow-tooltip>
      </el-table-column>
      <!-- <el-table-column prop="bankName" label="银行名称" min-width="120" show-overflow-tooltip>
      </el-table-column> -->
      <el-table-column prop="state" align="center" label="帐户状态" min-width="120" show-overflow-tooltip :formatter="formatStatus">
      </el-table-column>
      <el-table-column prop="userType" align="center" label="用户类别" min-width="120" :formatter="formatUserType">
      </el-table-column>
      <el-table-column label="操作" align="center" fixed='right' width="250">
        <template scope="scope">
          <el-col :xs="6" :sm="6" :md="6" :lg="6">
            <el-button size="small" v-show="customDetail" @click="handleDetail(scope.$index, scope.row)">详情</el-button>
          </el-col>
          <el-col :xs="6" :sm="6" :md="6" :lg="6">
            <el-button type="warning" size="small" :disabled="configUser()" v-show="showEidtbtn(scope.$index, scope.row)" @click="handleEdit(scope.$index, scope.row)">修改</el-button>
          </el-col>
          <el-col :xs="6" :sm="6" :md="6" :lg="6">
            <el-button type="danger" size="small" :disabled="ApproveUser(scope.$index,scope.row)" v-show="showApprove(scope.$index,scope.row)" @click="handleApprove(scope.$index, scope.row, '8')">审批</el-button>
          </el-col>
          <el-col :xs="6" :sm="6" :md="6" :lg="6">
            <el-button type="primary" size="small" :disabled="configUser()" v-show="IsshopRate(scope.$index, scope.row)" @click="handleshopRate(scope.$index, scope.row)">佣金</el-button>
          </el-col>
          <el-col :xs="6" :sm="6" :md="6" :lg="6">
            <el-button type="success" v-show="IsshopRateE(scope.$index, scope.row)" size="small" @click="handlePropelling(scope.$index, scope.row)">推送</el-button>
          </el-col>

        </template>
      </el-table-column>
    </el-table>

    <!--工具条-->
    <el-col :span="24" class="toolbar">
      <!-- <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button> -->
      <el-button type="warning" size="small" v-show="setCustomBrokerage" @click="commission">配置用户佣金</el-button>
      <el-button type="warning" size="small" @click="business" v-show="agreeBrokerage">配置代码佣金</el-button>
      <el-button type="warning" size="small" v-show="approveAgreeBrokerage" @click="approveBusiness" >审批代码佣金</el-button>
      <el-button type="warning" v-show="agreeBrokerageDetail" size="small" @click="particularsBusiness">代码佣金明细</el-button>
      <el-pagination style="float:right" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="page" :page-sizes="[10, 20, 40, 80]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </el-col>
    <!--新增界面-->
    <el-dialog title="新增" size="large" v-model="addFormVisible" :close-on-click-modal="false">
      <el-form :model="addForm" label-width="120px" :rules="addFormRules" ref="addForm">
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="真实姓名:" prop="userName">
              <el-input v-model="addForm.userName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="昵称:" prop="nickName">
              <el-input v-model="addForm.nickName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="密码:" prop="newPassword">
              <el-input placeholder="请输入明文，如00000" v-model="addForm.newPassword" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="用户的性别:" prop="wxSex">
              <el-select size="middle" clearable v-model="addForm.wxSex" placeholder="请选择">
                <el-option label="男" value="1"></el-option>
                <el-option label="女" value="0"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="手机号:" prop="mobile">
              <el-input v-model="addForm.mobile" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="证件类型:">
              <el-select size="middle" clearable v-model="addForm.idType" placeholder="请选择">
                <el-option label="身份证" value="1"></el-option>
                <el-option label="社会信用代码" value="2"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="证件号码:" prop="idNumber">
              <el-input v-model.number="addForm.idNumber" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="电子邮箱:" prop="email">
              <el-input v-model="addForm.email" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>

        </el-row>

        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="用户类别:" prop="userType">
              <el-select size="middle" clearable v-model="addForm.userType" placeholder="请选择用户类别">
                <el-option label="游客" value="1"></el-option>
                <el-option label="普通客户" value="2"></el-option>
                <el-option label="专业代理" value="3"></el-option>
                <el-option label="商户" value="4"></el-option>
                <el-option label="销售人员" value="5"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="分公司机构编码:" prop="branchCode">
              <el-input v-model="addForm.branchCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="业务关系代码:" prop="agrementNo">
              <el-input v-model="addForm.agrementNo" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="业务关系代码代理名称:" prop="agrementName">
              <el-input v-model="addForm.agrementName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售渠道编码:" prop="channelCode">
              <el-input v-model="addForm.channelCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售渠道名称:" prop="channelName">
              <el-input v-model="addForm.channelName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售人员编码:" prop="saleCode">
              <el-input v-model="addForm.saleCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售人姓名" prop="saleName">
              <el-input v-model="addForm.saleName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="常驻地区编码:" prop="areaCode">
              <el-input v-model="addForm.areaCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="常驻地区名:" prop="areaName">
              <el-input v-model="addForm.areaName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="邮寄配送地址:" prop="shippingAddress">
              <el-input v-model="addForm.shippingAddress" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="申请业务关系代码类型:" prop="applyAgrNoType">
              <el-select size="middle" clearable v-model="addForm.applyAgrNoType" placeholder="请选择代码类型">
                <el-option label="保险中介机构" value="1"></el-option>
                <el-option label="代理人" value="2"></el-option>
                <el-option label="非保险机构" value="3"></el-option>
              </el-select>
            </el-form-item>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="是否店主:" prop="storeFlag">
              <el-select size="middle" clearable v-model="addForm.storeFlag" placeholder="请选择是否店主">
                <el-option label="是" value="1"></el-option>
                <el-option label="否" value="0"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="商店介绍:" prop="shopIntroduct">
              <el-input v-model="addForm.shopIntroduct" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="商店名称:" prop="shopName">
              <el-input v-model="addForm.shopName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="用户积分余额:" prop="points">
              <el-input v-model="addForm.points" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="成交量/人气/显示/不显示:" prop="typeState">
              <el-select size="middle" clearable v-model="addForm.typeState" placeholder="请选择">
                <el-option label="显示" value="1"></el-option>
                <el-option label="不显示" value="0"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="人气:" prop="productCname">
              <el-input v-model="addForm.popularity" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="登录次数:" prop="productCname">
              <el-input v-model="addForm.loginTimes" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="连续登陆天数:" prop="productCname">
              <el-input v-model="addForm.loginTimesContinuity" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="介绍人ID:" prop="introduceId">
              <el-input v-model="addForm.introduceId" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="推荐进入的产品id:" prop="refereePro">
              <el-input v-model="addForm.refereePro" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="推荐人ID:" prop="refereeId">
              <el-input v-model="addForm.refereeId" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="备注:" prop="wxRemark">
              <el-input v-model="addForm.wxRemark" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="客户单位类型:" prop="introduceId">
              <el-input v-model="addForm.channelType" auto-complete="off" placeholder="例如W0204"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="客户单位名称:" prop="refereePro">
              <el-input v-model="addForm.customName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="归属部门:" prop="wxRemark">
              <el-input v-model="addForm.comCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="等级:" prop="productCname">
              <el-input v-model="addForm.level" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="下级佣金比例:" prop="introduceId">
              <el-input v-model="addForm.baseRate" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <!-- <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="是否审批佣金比例:" prop="refereeId">
              <el-select size="middle" clearable v-model="addForm.configSerialNo" placeholder="请选择">
                <el-option label="是" value="1"></el-option>
                <el-option label="否" value="0"></el-option>
              </el-select>
            </el-form-item>
          </el-col> -->
        </el-row>
      </el-form>
      <div slot="footer" align="center" class="dialog-footer">
        <el-button @click.native="addFormVisible = false">取消</el-button>
        <el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button>
      </div>
    </el-dialog>

    <!--详情界面-->
    <el-dialog title="详情" size="large" v-model="detailFormVisible" :close-on-click-modal="false">
      <el-form :model="detailForm" label-width="120px" :rules="detailFormRules" ref="detailForm">
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="客户ID:" prop="productCname">
              <el-input v-model="detailForm.id" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="真实姓名:" prop="productCname">
              <el-input v-model="detailForm.userName" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="用户的性别:" prop="wxSex">
              <el-select size="middle" clearable v-model="detailForm.wxSex" placeholder="请选择">
                <el-option label="男" value="1"></el-option>
                <el-option label="女" value="0"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="业务关系代码代理名称:" prop="agrementName">
              <el-input v-model="detailForm.agrementName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="昵称:" prop="productCname">
              <el-input v-model="detailForm.nickName" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="手机号:" prop="productCname">
              <el-input v-model="detailForm.mobile" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="证件类型:">
              <el-select size="middle" clearable v-model="detailForm.idType" placeholder="请选择">
                <el-option label="身份证" value="1"></el-option>
                <el-option label="社会信用代码" value="2"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="证件号码:" prop="idNumber">
              <el-input v-model.number="detailForm.idNumber" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="电子邮箱:" prop="productCname">
              <el-input v-model="detailForm.email" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="业务关系代码:" prop="productCname">
              <el-input v-model="detailForm.agrementNo" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="常驻地区编码:" prop="areaCode">
              <el-input v-model="detailForm.areaCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="申请业务关系代码类型:" prop="applyAgrNoType">
              <el-select size="middle" clearable v-model="detailForm.applyAgrNoType" placeholder="请选择代码类型">
                <el-option label="保险中介机构" value="1"></el-option>
                <el-option label="代理人" value="2"></el-option>
                <el-option label="非保险机构" value="3"></el-option>
              </el-select>
            </el-form-item>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售渠道名称:" prop="productCname">
              <el-input v-model="detailForm.channelName" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售渠道编码:" prop="productCname">
              <el-input v-model="detailForm.channelCode" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="商店介绍:" prop="shopIntroduct">
              <el-input v-model="detailForm.shopIntroduct" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="商店名称:" prop="shopName">
              <el-input v-model="detailForm.shopName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="用户积分余额:" prop="points">
              <el-input v-model="detailForm.points" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="人气" prop="productCname">
              <el-input v-model="detailForm.popularity" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="成交量" prop="productCname">
              <el-input v-model="detailForm.typeState" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="备注:">
              <el-input v-model="detailForm.wxRemark" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="登录次数:">
              <el-input v-model="detailForm.loginTimes" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="连续登陆天数:">
              <el-input v-model="detailForm.loginTimesContinuity" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售人姓名">
              <el-input v-model="detailForm.saleName" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售人编码">
              <el-input v-model="detailForm.saleCode" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="推荐进入的产品id:" prop="refereePro">
              <el-input v-model="detailForm.refereePro" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="推荐人ID:" prop="refereeId">
              <el-input v-model="detailForm.refereeId" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="介绍人ID:">
              <el-input v-model="detailForm.introduceId" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="客户编码:">
              <el-input v-model="detailForm.userCode" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="密码:" prop="productCname">
              <el-input v-model="detailForm.password" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="等级:" prop="productCname">
              <el-input v-model="detailForm.level" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="归属部门:" prop="wxRemark">
              <el-input v-model="detailForm.comCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="用户类别:" prop="productCname">
              <el-input v-model="detailForm.userType" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="下级佣金比例:" prop="introduceId">
              <el-input v-model="detailForm.baseRate" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="是否审批佣金比例:" prop="refereeId">
              <el-select size="middle" clearable v-model="detailForm.configSerialNo" placeholder="请选择">
                <el-option label="是" value="1"></el-option>
                <el-option label="否" value="0"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="OPENID:" prop="productCname">
              <el-input v-model="detailForm.wxOpenId" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="注册时间:" prop="productCname">
              <el-input v-model="detailForm.registeDate" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="上次登陆时间:" prop="productCname">
              <el-input v-model="detailForm.lastloginDate" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="配送地址:" prop="productCname">
              <el-input v-model="detailForm.shippingAddress" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="常驻地区:" prop="productCname">
              <el-input v-model="detailForm.address" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="帐户状态:" prop="productCname">
              <el-input v-model="detailForm.state" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="客户单位名称:" prop="customName">
              <el-input v-model="detailForm.customName" :readonly="true" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="客户单位类型:" prop="channelType">
              <el-input v-model="detailForm.channelType" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="分公司编码:" prop="productCname">
              <el-input v-model="detailForm.branchCode" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="头像路径:" prop="productCname">
              <el-input v-model="detailForm.headUrl" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="是否店主:" prop="productCname">
              <el-input v-model="detailForm.storeFlag" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="开店时间:" prop="productCname">
              <el-input v-model="detailForm.storeCreateTime" :readonly='true' auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <!-- <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="人气" prop="productCname">
              <el-input v-model="detailForm.popularity" auto-complete="off"></el-input>
            </el-form-item>
          </el-col> -->
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click.native="detailFormVisible = false">取消</el-button>
        <!-- <el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button> -->
      </div>
    </el-dialog>

    <!--修改界面-->
    <el-dialog title="修改" size="large" v-model="editFormVisible" :close-on-click-modal="false">
      <el-form :model="editForm" label-width="150px" :rules="editFormRules" ref="editForm">
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="真实姓名:" prop="userName">
              <el-input v-model="editForm.userName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="昵称:" prop="nickName">
              <el-input v-model="editForm.nickName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="密码:" prop="newPassword">
              <el-input placeholder="请输入明文，如00000" v-model="editForm.newPassword" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="用户的性别:" prop="wxSex">
              <el-select size="middle" clearable v-model="editForm.wxSex" placeholder="请选择">
                <el-option label="男" value="1"></el-option>
                <el-option label="女" value="0"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="手机号:" prop="mobile">
              <el-input v-model="editForm.mobile" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="证件类型:">
              <el-select size="middle" clearable v-model="editForm.idType" placeholder="请选择">
                <el-option label="身份证" value="1"></el-option>
                <el-option label="社会信用代码" value="2"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="证件号码:" prop="idNumber">
              <el-input v-model="editForm.idNumber" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="电子邮箱:" prop="email">
              <el-input v-model="editForm.email" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>

        </el-row>

        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="用户类别:" prop="userType">
              <el-select size="middle" clearable v-model="editForm.userType" placeholder="请选择用户类别">
                <el-option label="游客" value="1"></el-option>
                <el-option label="普通客户" value="2"></el-option>
                <el-option label="专业代理" value="3"></el-option>
                <el-option label="商户" value="4"></el-option>
                <el-option label="销售人员" value="5"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="分公司机构编码:" prop="branchCode">
              <el-input v-model="editForm.branchCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="业务关系代码:" prop="agrementNo">
              <el-input v-model="editForm.agrementNo" :disabled="isChannelUser" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="业务关系代码代理名称:" prop="agrementName">
              <el-input v-model="editForm.agrementName" :disabled="isChannelUser" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售渠道编码:" prop="channelCode">
              <el-input v-model="editForm.channelCode" :disabled="isChannelUser"  auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售渠道名称:" prop="channelName">
              <el-input v-model="editForm.channelName" :disabled="isChannelUser" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售人员编码:" prop="saleCode">
              <el-input v-model="editForm.saleCode" :disabled="isChannelUser" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="销售人姓名" prop="saleName">
              <el-input v-model="editForm.saleName" :disabled="isChannelUser" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="常驻地区编码:" prop="areaCode">
              <el-input v-model="editForm.areaCode" :disabled="isChannelUser"  auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="常驻地区名:" prop="areaName">
              <el-input v-model="editForm.areaName" :disabled="isChannelUser"  auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="邮寄配送地址:" prop="shippingAddress">
              <el-input v-model="editForm.shippingAddress" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="申请业务关系代码类型:" prop="applyAgrNoType">
              <el-select size="middle" clearable v-model="editForm.applyAgrNoType" placeholder="请选择代码类型">
                <el-option label="保险中介机构" value="1"></el-option>
                <el-option label="代理人" value="2"></el-option>
                <el-option label="非保险机构" value="3"></el-option>
              </el-select>
            </el-form-item>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="是否店主:" prop="storeFlag">
              <el-select size="middle" clearable v-model="editForm.storeFlag" placeholder="请选择是否店主">
                <el-option label="是" value="1"></el-option>
                <el-option label="否" value="0"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="商店介绍:" prop="shopIntroduct">
              <el-input v-model="editForm.shopIntroduct" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="商店名称:" prop="shopName">
              <el-input v-model="editForm.shopName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="用户积分余额:" prop="points">
              <el-input v-model="editForm.points" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="成交量/人气/显示/不显示:" prop="typeState">
              <el-input v-model="editForm.typeState" auto-complete="off" placeholder="第一位是成交量第二位人气第三位是否显示"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="人气:" prop="productCname">
              <el-input v-model="editForm.popularity" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="登录次数:" prop="productCname">
              <el-input v-model="editForm.loginTimes" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="连续登陆天数:" prop="productCname">
              <el-input v-model="editForm.loginTimesContinuity" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="介绍人ID:" prop="introduceId">
              <el-input v-model="editForm.introduceId" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="推荐进入的产品id:" prop="refereePro">
              <el-input v-model="editForm.refereePro" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="推荐人ID:" prop="refereeId">
              <el-input v-model="editForm.refereeId" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="备注:" prop="wxRemark">
              <el-input v-model="editForm.wxRemark" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="客户单位类型:" prop="introduceId">
              <el-input v-model="editForm.channelType"  :disabled="isChannelUser" auto-complete="off" placeholder="例如W0204"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="客户单位名称:" prop="refereePro">
              <el-input v-model="editForm.customName" :disabled="isChannelUser" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="归属部门:" prop="wxRemark">
              <el-input v-model="editForm.comCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="等级:" prop="productCname">
              <el-input v-model="editForm.level" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="下级佣金比例:" prop="introduceId">
              <el-input v-model="editForm.baseRate" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <!-- <el-col :xs="20" :sm="12" :md="6" :lg="6">
            <el-form-item label="是否审批佣金比例:" prop="refereeId">
              <el-select size="middle" clearable v-model="editForm.configSerialNo" placeholder="请选择">
                <el-option label="是" value="1"></el-option>
                <el-option label="否" value="0"></el-option>
              </el-select>
            </el-form-item>
          </el-col> -->
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click.native="editFormVisible = false">取消</el-button>
        <el-button type="primary" @click.native="editSubmit" :loading="editLoading">提交</el-button>
      </div>
    </el-dialog>

    <!--配置佣金界面-->
    <el-dialog title="配置佣金比例" v-model="commissionFormVisible" :close-on-click-modal="false">
      <el-row style="margin-bottom:20px;">
        <el-collapse>
          <el-collapse-item title="已选择用户" name="1">
            <div>{{selectionNames}}</div>
          </el-collapse-item>
        </el-collapse>
      </el-row>
      <el-row>
        <el-table :data="commissiondata" stripe border :height="winHeight-320" v-loading="commissiondataLoading" @select-all="commissionselsAll" @select="commissionselsChange" @cell-dblclick="dblclick" highlight-current-row ref="producttable">
          <el-table-column align="center" type="selection" width="55">
          </el-table-column>
          <el-table-column align="center" prop="productname" label="产品名称" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="productEname" label="产品英文名" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" width="180" label="比例(可双击修改)">
            <template scope="scope">
              <span v-show="Isinput(scope.row.id,InputStatus,false)">{{scope.row.rate}}</span>
              <el-tooltip class="item" effect="dark" v-show="Isinput(scope.row.id,InputStatus,true)" content="请输入0-1" placement="top">
                <el-input v-model="scope.row.rate" @blur="inputblur(scope.row)" style="width:80%;" auto-complete="off"></el-input>
              </el-tooltip>
              <span v-show="helpValidate(scope.row.rate,scope.$index)" class="help-block">{{helptext(scope.row.rate)}}</span>
            </template>
          </el-table-column>
        </el-table>
        <!--工具条-->
        <el-col :span="24" class="toolbar">
          <el-pagination style="float:right" @size-change="commissionSizeChange" @current-change="commissionCurrentChange" :current-page="commissionpage" :page-sizes="[10,20,40]" :page-size="commissionpageSize" layout="total, sizes, prev, pager, next, jumper" :total="commissiontotal">
          </el-pagination>
        </el-col>
      </el-row>
      <div slot="footer" align="center" class="dialog-footer">
        <el-button @click.native="commissionFormVisible = false">取消</el-button>
        <el-button type="primary" @click.native="commissionSubmit" :loading="commissionLoading">提交</el-button>
      </div>
    </el-dialog>

    <!--配置业务关系代码佣金界面-->
    <el-dialog title="配置业务关系代码佣金比例" v-model="businessFormVisible" :close-on-click-modal="false">
      <el-form :model="agreementNoForm" label-width="150px" :rules="agreementNoFormRules" ref="agreementNoForm">
        <el-row :gutter="20">
          <el-col :xs="24" :sm="20" :md="16" :lg="12">
            <el-form-item label="业务关系代码:" prop="agreementNo">
              <el-input v-model="agreementNoForm.agreementNo" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-row>
        <el-table :data="businessdata" stripe border :height="winHeight-320" v-loading="businessdataLoading" @select-all="businessselsAll" @select="businessselsChange" @cell-dblclick="dblclick" highlight-current-row ref="producttable">
          <el-table-column align="center" type="selection" width="55">
          </el-table-column>
          <el-table-column align="center" prop="productname" label="产品名称" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="productEname" label="产品英文名" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" width="180" label="比例(可双击修改)">
            <template scope="scope">
              <span v-show="Isinput(scope.row.id,InputStatus,false)">{{scope.row.rate}}</span>
              <el-tooltip class="item" effect="dark" v-show="Isinput(scope.row.id,InputStatus,true)" content="请输入0-1" placement="top">
                <el-input v-model="scope.row.rate" @blur="inputblur(scope.row)" style="width:80%;" auto-complete="off"></el-input>
              </el-tooltip>
              <span v-show="helpValidate(scope.row.rate,scope.$index)" class="help-block">{{helptext(scope.row.rate)}}</span>
            </template>
          </el-table-column>
        </el-table>
        <el-col :span="24" class="toolbar">
          <el-pagination style="float:right" @size-change="businessSizeChange" @current-change="businessCurrentChange" :current-page="businesspage" :page-sizes="[10,20,40]" :page-size="businesspageSize" layout="total, sizes, prev, pager, next, jumper" :total="businesstotal">
          </el-pagination>
        </el-col>
      </el-row>
      <div slot="footer" align="center" class="dialog-footer">
        <el-button @click.native="businessFormVisible = false">取消</el-button>
        <el-button type="primary" @click.native="businessSubmit" :loading="businessLoading">提交</el-button>
      </div>
    </el-dialog>

    <!--审批业务关系代码佣金界面-->
    <el-dialog :title="'审批代码佣金'" v-model="approveBusinessFormVisible" :close-on-click-modal="false">
      <el-row>
        <el-table :data="approveBusinessdata" stripe border :height="winHeight-320" v-loading="approveBusinessLoading" highlight-current-row>
          <el-table-column align="center" prop="approveId" label="业务关系代码" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column label="操作" fixed='right' width="150">
            <template scope="scope">
              <el-button size="small" @click="handleApproveDetail(scope.$index, scope.row)">详情</el-button>
              <el-button type="danger" size="small" @click="handleApproveBus(scope.$index, scope.row, '9')" :disabled="ApproveUser(scope.$index, scope.row)">审批</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!--工具条-->
        <el-col :span="24" class="toolbar">
          <el-pagination style="float:right" @size-change="approveBusinessSizeChange" @current-change="approveBusinessCurrentChange" :current-page="approveBusinesspage" :page-sizes="[10,20,40]" :page-size="approveBusinesspageSize" layout="total, sizes, prev, pager, next, jumper" :total="approveBusinesstotal">
          </el-pagination>
        </el-col>
      </el-row>
    </el-dialog>

    <!--审批业务关系代码佣金详情界面-->
    <el-dialog :title="'详情'" v-model="approveDetailFormVisible" :close-on-click-modal="false">
      <el-row>
        <el-table :data="approveDetaildata" stripe border :height="winHeight-320" v-loading="approveDetailLoading" highlight-current-row>
          <el-table-column align="center" prop="productName" label="产品名称" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="productEname" label="产品英文名" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="agreementNo" label="业务关系代码" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="rate" min-width="100" label="比例">
          </el-table-column>
        </el-table>
        <!--工具条-->
        <!-- <el-col :span="24" class="toolbar">
          <el-pagination style="float:right" @size-change="approveDetailChange" @current-change="approveDetailCurrentChange" :current-page="approveDetailpage" :page-sizes="[10,20,40]" :page-size="approveDetailpageSize" layout="total, sizes, prev, pager, next, jumper" :total="approveDetailtotal">
          </el-pagination>
        </el-col> -->
      </el-row>
    </el-dialog>

    <!--查看佣金比例界面-->
    <el-dialog :title="'[ '+shopRateUser+' ] 佣金比例'" v-model="shopRateFormVisible" :close-on-click-modal="false">
      <el-row>
        <el-table :data="shopRatedata" stripe border :height="winHeight-320" v-loading="shopRateLoading" highlight-current-row>
          <el-table-column align="center" prop="productName" label="产品名称" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="product.productEname" label="产品英文名" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="addDate" label="添加时间" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="rate" min-width="100" label="比例">
          </el-table-column>
          <el-table-column label="操作" fixed='right' width="100">
            <template scope="scope">
              <el-button type="danger" size="small" @click="RateDel(scope.$index, scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!--工具条-->
        <el-col :span="24" class="toolbar">
          <el-pagination style="float:right" @size-change="shopRateSizeChange" @current-change="shopRateCurrentChange" :current-page="shopRatepage" :page-sizes="[10,20,40]" :page-size="shopRatepageSize" layout="total, sizes, prev, pager, next, jumper" :total="shopRatetotal">
          </el-pagination>
        </el-col>
      </el-row>
    </el-dialog>

    <!--查看代码佣金明细界面-->
    <el-dialog :title="'代码佣金明细'" v-model="particularsFormVisible" :close-on-click-modal="false">
      <el-row>
        <!--工具条-->
        <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
          <el-form :inline="true" :model="particulars">
            <el-row :gutter="40" style="padding-right: 10px;">
              <el-col :xs="24" :sm="12" :md="6" :lg="6" style="margin-top: 4px;">
                <el-input size="small" style="width:100%;" v-model.trim="particulars.agrementNo" placeholder="业务关系代码"></el-input>
              </el-col>
              <el-form-item style="float:right;">
                <el-button size="small" icon="search" type="primary" v-on:click="GetParticularsBusiness(true)">查询</el-button>
              </el-form-item>
            </el-row>
          </el-form>
        </el-col>
        <el-table :data="particularsdata" stripe border :height="winHeight-320" v-loading="particularsLoading" highlight-current-row>
          <el-table-column align="center" prop="productName" label="产品名称" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="product.productEname" label="产品英文名" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="agreementNo" label="业务关系代码" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="addDate" label="添加时间" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="rate" min-width="100" label="比例">
          </el-table-column>
          <el-table-column label="操作" fixed='right' width="100">
            <template scope="scope">
              <el-button type="danger" size="small" @click="particularsDel(scope.$index, scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!--工具条-->
        <el-col :span="24" class="toolbar">
          <el-pagination style="float:right" @size-change="particularsSizeChange" @current-change="particularsCurrentChange" :current-page="particularspage" :page-sizes="[10,20,40]" :page-size="particularspageSize" layout="total, sizes, prev, pager, next, jumper" :total="particularstotal">
          </el-pagination>
        </el-col>
      </el-row>
    </el-dialog>

    <!--审批佣金比例-->
    <el-dialog :title="'审批[ '+shopRateUser+' ] 佣金比例'" v-model="approveRateFormVisible" :close-on-click-modal="false">
      <el-row>
        <el-table :data="approveRatedata" stripe border :height="winHeight-320" v-loading="shopRateLoading" highlight-current-row>
          <el-table-column align="center" prop="productName" label="产品名称" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="productEname" label="产品英文名" min-width="180" show-overflow-tooltip>
          </el-table-column>
          <el-table-column align="center" prop="rate" min-width="100" label="比例">
          </el-table-column>
        </el-table>
      </el-row>
      <div slot="footer" align="center" class="dialog-footer">
        <el-button type="primary" v-show="true" @click.native="agreeApprove('yes', theApproveType)" :loading="detailLoading">同意</el-button>
        <!--  @click.native="submit(submitStatus)"  -->
        <el-button @click.native="agreeApprove('no', theApproveType)">拒绝</el-button>
      </div>
    </el-dialog>
    <!--审批佣金比例-->

    <!--批量开户界面-->
    <el-dialog title="批量开户" size="tiny" v-model="matchFormVisible" :close-on-click-modal="false">
      <el-form :model="matchForm" label-width="120px" ref="matchForm" :rules="matchFormRules" :inline="true">
        <el-row>
          <el-col :xs="24" :sm="24" :md="24" :lg="24">
            <el-form-item label="产品ID:" prop="productids">
              <el-input v-model.trim="matchForm.productids" auto-complete="off" placeholder="请输入产品ID">
              </el-input>
            </el-form-item>
          </el-col>
          <!-- <el-col :xs="24" :sm="24" :md="24" :lg="24">
              <el-form-item label="产品结束ID:" prop="e_productid">
                <el-input v-model.trim="matchForm.e_productid" auto-complete="off" placeholder="请输入产品结束ID">
                </el-input>
              </el-form-item>
            </el-col> -->
          <el-col align="center">
            <el-button type="primary" @click.native="matchSubmit" :loading="matchLoading">确定</el-button>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>

    <!-- 推送界面 -->
    <el-dialog title="指定推送" v-model="propellingVisible" :close-on-click-modal="false">
      <el-form :model="propelling" label-width="100px" ref="propelling" :rules="sendFormRules" >
        <el-row>
          <el-col :xs="24" :sm="24" :md="12" :lg="12">
            <el-form-item label="触发类型:" prop="type">
              <el-select v-model="propelling.type" class="otherWidth" placeholder="请选择触发类型" @change="typeChange(propelling.type)">
                <el-option label="出单-规则" value="1"></el-option>
                <el-option label="出单-活动" value="2"></el-option>
                <el-option label="抽奖-活动" value="3"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :sm="24" :md="12" :lg="12" v-show="typeOfRule">
            <el-form-item label="保单号:" prop="policyNo">
              <el-input v-model.trim="propelling.policyNo" style="width:100%;" auto-complete="off" placeholder="请输入保单号">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="12" :lg="12" v-show="typeOfRule">
            <el-form-item label="出单宝豆:" prop="beans">
              <el-input v-model="propelling.beans" style="width:100%;" auto-complete="off" placeholder="请输入出单宝豆">
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :xs="24" :sm="24" :md="12" :lg="12" v-show="typeOfActivity">
            <el-form-item label="活动名称:" prop="activityName">
              <el-input v-model.trim="propelling.activityName" style="width:100%;" auto-complete="off" placeholder="请输入活动名称">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="12" :lg="12" v-show="typeOfActivity">
            <el-form-item label="活动宝豆:" prop="beans">
              <!-- :rules="[
              { require:false,type: 'number', message: '活动宝豆必须为数字值'}
               ]" -->
              <el-input v-model="propelling.beans" style="width:100%;" auto-complete="off" placeholder="请输入活动宝豆">
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :xs="24" :sm="24" :md="12" :lg="12" v-show="typeOfDraw">
            <el-form-item label="抽奖次数:" prop="times">
              <!--  :rules="[
              {require:false, type: 'number', message: '抽奖次数必须为数字值'}
               ]" -->
              <el-input v-model="propelling.times" style="width:100%;" auto-complete="off" placeholder="请输入抽奖次数">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="12" :lg="12" v-show="typeOfDraw">
            <el-form-item label="活动名称:" prop="activityName">
              <el-input v-model.trim="propelling.activityName" style="width:100%;" auto-complete="off" placeholder="请输入活动名称">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click.native="propellingVisible = false">取消</el-button>
        <el-button type="primary" @click.native="addSubmitPush" :loading="addLoading">提交</el-button>
      </div>
    </el-dialog>

  </section>
</template>

<script>
import util from '../../common/js/util'

import commons from '../../common/js/common'
import { mapState, mapActions } from 'vuex'
//import NProgress from 'nprogress'
import { userList, codeNodeList, updateUser, getUserListPage, setShopRate, shopRate, deleteShopRate, addUser, createUsers, approveActivity, reissue, waitAapprove, agreeRate, deleteAgreeRate } from '../../api/api';

export default {
  data() {
    // /^0{0,1}(13[4-9]|15[7-9]|15[0-2]|18[7-8])[0-9]{8}$/
    var phone = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('手机号码不能为空'));
      }
      else {
        if (!(/^\d{11}$/.test(value))) {
          callback(new Error('请输入正确的手机号码'));
        }
        else {
          callback();
        }
      }
    };
    var numberText = (rule, value, callback) => {
      if (this.typeOfRule||this.typeOfActivity) {
          if (!value) {
              return callback(new Error('宝豆量不能为空'));
          }
          else {
              if (!(/^[0-9]*$/.test(value))) {
                return callback(new Error('请输入数字'));
              }
              else {
                return callback();
              }
          }
      }else{
        return callback();
      }
    };
    var typeOfDraw = (rule, value, callback) => {
      if (this.typeOfDraw) {
          if (!value) {
              return callback(new Error('抽奖次数不能为空'));
          }
          else {
              if (!(/^[0-9]*$/.test(value))) {
                return callback(new Error('请输入数字'));
              }
              else {
                return callback();
              }
          }
      }else{
        return callback();
      }
    };
    var IDCardValid = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('证件号码不能为空'));
        }
        else {
          if (this.editForm.idType==1||this.addForm.idType==1) {
            if (!(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value))) {
              return callback(new Error('请输入正确的身份证号码'));
            }else{
              return callback();
            }
          }
          else {  
             return callback();
        }
      }
    };
    return {
      pickerOptions0: {
        disabledDate(time) {
          return time.getTime() > Date.now() - 8.64e7;
        }
      },
      lists: [],
      filters: {
        items: '',
        id: '',
        userName: '',
        nickName: '',
        mobile: '',
        email: '',
        agrementNo: '',
        branchCode: '',
        signStartTime: '',
        signEndTime: '',
        Minpoints: '',
        Maxpoints: '',
        storeFlag: '',
        userType: '',
        storeCreateTime:''
      },
      particulars: {
        agrementNo: ''
      },
      approveUserCode: '',
      customs: [],
      commissiondata: [],
      businessdata: [],
      IsValidate: [],
      total: 0,
      page: 1,
      pageSize: 10,
      commissiontotal: 0,
      commissionpage: 1,
      commissionpageSize: 10,
      businesstotal: 0,
      businesspage: 1,
      businesspageSize: 10,
      listLoading: false,
      exportTotal: 0,
      loading: '',
      selectionNames: '',
      sels: [],//列表选中列
      commissionsels: [],
      businesssels: [],
      Isloading: false,
      InputStatus: false,//是否编辑比列
      InpitId: '',//编辑比例ID
      rateData: [],
      userrow: {},
      isChannelUser:false, 
      shopRateUser: '',
      shopRatetotal: 0,
      shopRatepage: 1,
      shopRatepageSize: 10,
      shopRateFormVisible: false,
      particularstotal: 0,
      particularspage: 1,
      particularspageSize: 10,
      particularsFormVisible: false,
      approveBusinesstotal: 0,
      approveBusinesspage: 1,
      approveBusinesspageSize: 10,
      approveBusinessFormVisible: false,
      approveDetailtotal: 0,
      approveDetailpage: 1,
      approveDetailpageSize: 10,
      approveDetailFormVisible: false,
      shopRatedata: [],
      particularsdata: [],
      approveRatedata: [],
      approveBusinessdata: [],
      approveDetaildata: [],
      shopRateLoading: false,
      particularsLoading: false,
      approveBusinessLoading: false,
      approveDetailLoading: false,
      editFormVisible: false,//修改界面是否显示
      matchFormVisible: false,//批量开户是否显示
      addFormVisible: false,
      editLoading: false,
      commissionFormVisible: false,//佣金界面是否显示
      commissiondataLoading: false,
      businessFormVisible: false,//佣金界面是否显示
      businessdataLoading: false,
      detailLoading: false,
      approveRateFormVisible: false,//审批佣金比例是否显示
      theApproveType: '',
      matchLoading: false,
      commissionLoading: false,
      businessLoading: false,
      agreeBrokerage: false,
      agreeBrokerageDetail: false,
      approveAgreeBrokerage: false,
      customAdd: false,
      customApprove: false,
      customBatchAdd: false,
      customBrokerage: false,
      customDetail: false,
      customExport: false,
      customQuery: false,
      customSend: false,
      customUpdate: false,
      setCustomBrokerage: false,

      editFormRules: {
        userName: [
          { required: true, message: '请输入真实姓名', trigger: 'blur' }
        ],
        idNumber: [
          { required: true,  validator: IDCardValid, trigger: 'blur' }
        ],
        // agrementNo: [
        //   { required: true, message: '请输入业务关系代码', trigger: 'blur' }
        // ],
      },
      matchFormRules: {
        productids: [
          { required: true, message: '请输入产品ID', trigger: 'blur' }
        ]
      },
      agreementNoForm: {
        agreementNo: ''
      },
      agreementNoFormRules: {
        agreementNo: [
          { required: true, message: '请输入业务关系代码', trigger: 'blur' }
        ],
      },
      //修改界面数据
      editForm: {
        userName: '',
        nickName: '',
        mobile: '',
        email: '',
        agrementNo: '',
        channelName: '',
        channelCode: '',
        saleName: '',
        saleCode: '',
        userCode: '',
        newPassword: '',
        level: '',
        wxOpenId: '',
        registeDate: '',
        lastloginDate: '',
        shippingAddress: '',
        address: '',
        state: '',
        branchCode: '',
        headUrl: '',
        storeFlag: '',
        userType: '',
        agrementName: '',
        applyAgrNoType: '',
        areaCode: '',
        areaName: '',
        idNumber: '',
        introduceId: '',
        loginState: '',
        loginTimes: '',
        loginTimesContinuity: '',
        points: '',
        popularity: '',
        refereePro: '',
        refereeId: '',
        shopIntroduct: '',
        shopName: '',
        storeCreateTime: '',
        typeState: '',
        userCodeBs: '',
        channelType: '',
        comCode: '',
        shopIntroduc: '',
        configSerialNo: '',
        idType: '',
        baseRate: ''
      },
      addForm: {
        userName: '',
        nickName: '',
        mobile: '',
        email: '',
        agrementNo: '',
        channelName: '',
        channelCode: '',
        saleName: '',
        saleCode: '',
        userCode: '',
        newPassword: '',
        level: '',
        wxOpenId: '',
        registeDate: '',
        lastloginDate: '',
        shippingAddress: '',
        address: '',
        state: '',
        branchCode: '',
        headUrl: '',
        storeFlag: '',
        userType: '',
        agrementName: '',
        applyAgrNoType: '',
        areaCode: '',
        areaName: '',
        idNumber: '',
        introduceId: '',
        loginState: '',
        loginTimes: '',
        loginTimesContinuity: '',
        points: '',
        popularity: '',
        refereePro: '',
        refereeId: '',
        shopIntroduct: '',
        shopName: '',
        storeCreateTime: '',
        typeState: '',
        userCodeBs: '',
        wxCity: '',
        wxCountry: '',
        wxGroupid: '',
        wxLanguage: '',
        wxProvince: '',
        wxRemark: '',
        wxSex: '',
        wxSubscribe: '',
        wxSubscribeTime: '',
        wxTagidList: '',
        channelType: '',
        comCode: '',
        shopIntroduc: '',
        configSerialNo: '',
        idType: '',
        baseRate: ''

      },
      detailFormVisible: false,//新增界面是否显示
      addLoading: false,
      detailFormRules: {
        // name: [
        //   { required: true, message: '请输入姓名', trigger: 'blur' }
        // ]
      },
      sendFormRules:{
        beans: [
          { required: true, validator: numberText, trigger: 'blur' }
        ],
        times: [
          { required: true, validator: typeOfDraw, trigger: 'blur' }
        ],
      },
      addFormRules: {
        userName: [
          { required: true, message: '请输入姓名', trigger: 'blur' }
        ],
        nickName: [
          { required: true, message: '请输入昵称', trigger: 'blur' }
        ],
        email: [
          // { required: true, message: '请输入邮箱地址', trigger: 'blur' },
          { required: false, type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur,change' }
        ],
        mobile: [
          { required: true, validator: phone, trigger: 'blur' },
        ],
        agrementNo: [
          { required: false, message: '请输入业务关系代码', trigger: 'blur' }
        ],
        channelName: [
          { required: false, message: '请输入销售渠道名称', trigger: 'blur' }
        ],
        channelCode: [
          { required: false, message: '请输入销售渠道编码', trigger: 'blur' }
        ],
        saleName: [
          { required: false, message: '请输入销售人姓名', trigger: 'blur' }
        ],
        saleCode: [
          { required: false, message: '请输入销售人员代码', trigger: 'blur' }
        ],
        userCode: [
          { required: false, message: '请输入客户编码', trigger: 'blur' }
        ],
        newPassword: [
          { required: true, message: '请输入密码', trigger: 'blur' }
        ],
        shippingAddress: [
          { required: false, message: '请输入配送地址', trigger: 'blur' }
        ],
        branchCode: [
          { required: false, message: '请输入分公司编码', trigger: 'blur' }
        ],
        storeFlag: [
          { required: true, message: '请选择是否为店主', trigger: 'blur' }
        ],
        userType: [
          { required: true, message: '请输入用户类别', trigger: 'blur' }
        ],
        agrementName: [
          { required: false, message: '请输入业务代理名称', trigger: 'blur' }
        ],
        applyAgrNoType: [
          { required: false, message: '请输入业务代理类型', trigger: 'blur' }
        ],
        areaCode: [
          { required: false, message: '请输入常驻地区编码', trigger: 'blur' }
        ],
        areaName: [
          { required: false, message: '请输入常驻地区名', trigger: 'blur' }
        ],
        idNumber: [
          { required: true,  validator: IDCardValid, trigger: 'blur' }
        ],
        introduceId: [
          { required: false, message: '请输入介绍人ID', trigger: 'blur' }
        ],
        points: [
          { required: true, message: '请输入用户积分余额', trigger: 'blur' }
        ],
        refereePro: [
          { required: false, message: '请输入推荐进入的产品ID', trigger: 'blur' }
        ],
        refereeId: [
          { required: false, message: '请输入介绍人ID', trigger: 'blur' }
        ],
        shopIntroduct: [
          { required: false, message: '请输入商店介绍', trigger: 'blur' }
        ],
        shopName: [
          { required: false, message: '请输入商店名称', trigger: 'blur' }
        ],
        wxSex: [
          { required: true, message: '请选择用户性别', trigger: 'blur' }
        ],
        wxRemark: [
          { required: false, message: '请输入备注', trigger: 'blur' }
        ],
        typeState: [
          { required: true, message: '请选择是否显示', trigger: 'blur' }
        ]
      },
      //详情界面数据
      detailForm: {
        id: '',
        userCode: '',
        userName: '',
        password: '',
        nickName: '',
        level: '',
        wxOpenId: '',
        registeDate: '',
        lastloginDate: '',
        mobile: '',
        shippingAddress: '',
        address: '',
        headUrl: '',
        agrementNo: '',
        customName: '',
        channelType: '',
        bankUser: '',
        bankAccount: '',
        bankName: '',
        state: '',
        email: '',
        introduceId: '',
        refereeId: '',
        branchCode: '',
        points: '',
        storeFlag: '',
        userType: '',
        comCode: '',
        shopIntroduc: '',
        configSerialNo: '',
        idType: '',
        idNumber: '',
        baseRate: ''
      },
      //批量开户
      matchForm: {
        productids: ''
      },
      propelling: {
        userCode: '',
        type: '',
        beans: '',
        activityName: '',
        policyNo: '',
        activityBeans: '',
        times: ''
      },
      propellingVisible: false,
      typeOfRule: false,
      typeOfActivity: false,
      typeOfDraw: false,
      userCodePush: '',

    }
  },
  computed: mapState([
    'user',
    'winWidth',
    'winHeight'
  ]),
  methods: {
    // 推送
    handlePropelling: function (index, row) {
      this.userCodePush = row.userCode;
      this.propellingVisible = true;
    },
    typeChange: function (value) {
      if (value == '1') {
        this.typeOfRule = true;
        this.typeOfActivity = false;
        this.typeOfDraw = false;
      } else if (value == '2') {
        this.typeOfActivity = true;
        this.typeOfDraw = false;
        this.typeOfRule = false;
      } else {
        this.typeOfDraw = true;
        this.typeOfActivity = false;
        this.typeOfRule = false;
      }
    },
    addSubmitPush: function () {
      let para = new FormData();
      para.append('userCode', this.userCodePush);
      para.append('beans', this.propelling.beans);
      para.append('activityName', this.propelling.activityName);
      para.append('policyNo', this.propelling.policyNo);
      para.append('times', this.propelling.times);
      para.append('type', this.propelling.type);
      // this.$refs.propelling.validate((valid) => {
      //   if (valid) {
      this.$confirm('确认提交吗？', '提示', {}).then(() => {
        this.addLoading = true;
        reissue(para).then((res) => {
          if (res.data.success) {
            this.$message({
              message: '提交成功',
              type: 'success'
            });
            this.propellingVisible = false;
            this.getcustoms(true);
          }
          else {
            this.$message({
              message: res.data.result,
              type: 'error'
            });
          }
        });
      });
    },
    formatStatus: function (row, column) {
      return row.state == "0" ? "已注销" : (row.state == "1" ? "有效" : "挂失");
    },
    formatStoreFlag: function (row, column) {
      return row.storeFlag == "1" ? "是" : "否";
    },
    formatUserType: function (row, column) {
      return commons.customType(row.userType);
    },
    formatProductCname: function (row, column) {
      return row.product.productCname;
    },
    selectables: function (row, index) {
      return row.storeFlag != "1" ? false : true;
    },
    //是否显示佣金
    IsshopRate: function (index, row) {
      if (this.customBrokerage) {
        return row.storeFlag != "1" ? false : true;
      } else {
        return false;
      }
    },
    IsshopRateE: function (index, row) {
      if (this.customUpdate) {
        return row.storeFlag != "1" ? false : true;
      } else {
        return false;
      }
    },
    handleCurrentChange(val) {
      this.page = val;
      this.getcustoms(true);
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.getcustoms(true);
    },
    commissionSizeChange(val) {
      this.commissionpageSize = val;
      this.Getproducts();
    },
    commissionCurrentChange(val) {
      this.commissionpage = val;
      this.Getproducts();
    },
    businessSizeChange(val) {
      this.businesspageSize = val;
      this.businessGetproducts();
    },
    businessCurrentChange(val) {
      this.businesspage = val;
      this.businessGetproducts();
    },
    shopRateSizeChange(val) {
      this.shopRatepageSize = val;
      // this.Getproducts();
      this.GetshopRate();
    },
    shopRateCurrentChange(val) {
      this.shopRatepage = val;
      // this.Getproducts();
      this.GetshopRate();
    },
    particularsSizeChange(val) {
      this.particularspageSize = val;
      this.GetParticularsBusiness();
    },
    particularsCurrentChange(val) {
      this.particularspage = val;
      this.GetParticularsBusiness();
    },
    approveBusinessSizeChange(val) {
      this.approveBusinesspageSize = val;
      this.GetApproveBusiness();
    },
    approveBusinessCurrentChange(val) {
      this.approveBusinesspage = val;
      this.GetApproveBusiness();
    },
    // approveDetailChange(val) {
    //   this.approveDetailpageSize = val;
    //   this.GetApproveDetail();
    // },
    // approveDetailCurrentChange(val) {
    //   this.approveDetailpage = val;
    //   this.GetApproveDetail();
    // },
    //获取用户列表
    getcustoms(bool) {
      // let para = {
      //   pageSize: 10,
      //   pageNumber: this.page,
      //   productCname:'',
      //   riskCode:'',
      //   startDate:'',
      //   endDate:''
      // };

      let para = new FormData();
      para.append("pageSize", bool ? this.pageSize : this.exportTotal);
      para.append("pageNumber", bool ? this.page : 1);
      para.append("userCode", this.filters.id);
      para.append("userName", this.filters.userName);
      para.append("nickName", this.filters.nickName);
      para.append("mobile", this.filters.mobile);
      // para.append("email",this.filters.email);
      para.append("agrementNo", this.filters.agrementNo);
      para.append("signStartTime", commons.changeTime(this.filters.signStartTime, 'start'));
      para.append("signEndTime", commons.changeTime(this.filters.signEndTime, 'end'));
      para.append("branchCode", this.filters.branchCode);
      para.append("Minpoints", this.filters.Minpoints);
      para.append("Maxpoints", this.filters.Maxpoints);
      para.append("storeFlag", this.filters.storeFlag);
      para.append("userType", this.filters.userType);
      para.append("storeStartDate", commons.changeTimes(this.filters.storeCreateTime, 'start'));
      para.append("storeEndDate", commons.changeTimes(this.filters.storeCreateTime, 'end'));
      this.listLoading = bool;
      //NProgress.start();

      if (!bool) {
        this.loading = this.$loading({
          lock: true,
          text: '正在导出',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
      }
      userList(para).then((res) => {
        this.total = res.data.result.totalElements;
        this.exportTotal = res.data.result.totalElements;
        this.lists = res.data.result.content;

        if (!bool) {
          this.loading.close();
          this.export2Excel();
        }
        else {
          this.Isloading = true;
          this.customs = res.data.result.content;
          this.$refs.table.clearSelection();
          if (this.sels) {
            for (var k in this.sels) {
              for (var i in this.customs) {
                if (this.customs[i].id == this.sels[k].id) {
                  this.$refs.table.toggleRowSelection(this.customs[i], true);
                }
              }
            }
          }
        }

        this.listLoading = false;
        //NProgress.done();
      });

      let branchList = new FormData();

      branchList.append("type", "BranchCode");

      codeNodeList(branchList).then((res) => {
        this.filters.items = res.data.result;
      });
    },
    //删除
    handleDel: function (index, row) {
      this.$confirm('确认删除该记录吗?', '提示', {
        type: 'warning'
      }).then(() => {
        this.listLoading = true;
        //NProgress.start();
        let para = new FormData();
        para.append("ids", row.id);
        removeAd(para).then((res) => {
          this.listLoading = false;
          //NProgress.done();
          this.$message({
            message: '删除成功',
            type: 'success'
          });
          this.getcustoms(true);
        });
      }).catch(() => {

      });
    },

    //table导出excel
    exportExcels: function () {
      this.getcustoms(false);
    },
    export2Excel: function () {
      require.ensure([], () => {
        const { export_json_to_excel } = require('../../vendor/Export2Excel');
        const tHeader = ['客户ID', '真实姓名', '昵称', '手机号', '电子邮箱', '业务关系代码', '推荐人客户编码', '客户编码', '密码', '等级', 'OPENID', '注册时间', '上次登陆时间', '配送地址', '常驻地区', '客户单位名称', '客户单位类型', '开户名称', '银行帐号', '银行名称', '开户行', '开户行省份', '开户行城市', '银行绑定手机号码', '是否有效', '分公司编码', '头像路径', '身份证号', '积分余额', '是否店主', '店主类别', '有效积分', '待生效积分', '总积分', '人气'];
        const filterVal = ['id', 'userName', 'nickName', 'mobile', 'email', 'agrementNo', 'refereeId', 'userCode', 'password', 'level', 'wxOpenId', 'registeDate', 'lastloginDate', 'shippingAddress', 'areaName', 'customName', 'channelType', 'bankUser', 'bankAccount', 'bankName', 'branchName', 'province', 'city', 'bankmobile', 'isValidate', 'branchCode', 'headUrl', 'idNumber', 'points', 'storeFlag', 'userType', 'effctiveScore', 'noeffctiveScore', 'sumScore', 'popularity'];
        const list = this.lists;
        for (var i in list) {
          // list[i].registeDate = commons.getDaytime(list[i].registeDate, 1, false);
          // list[i].lastloginDate = commons.getDaytime(list[i].lastloginDate, 1, false);
          list[i].storeFlag = list[i].storeFlag == "1" ? "是" : "否";
          list[i].userType = commons.customType(list[i].userType);
          list[i].branchName = "";
          list[i].province = "";
          list[i].city = "";
          list[i].bankmobile = "";
          if (list[i].agrementNo == '' || list[i].agrementNo == null) {
            list[i].channelType = null;
            list[i].customName = null;
          }
          if (list[i].refereeUser) {
            list[i].refereeId = list[i].refereeUser.id;
          }
          if (list[i].banks) {
            list[i].bankUser = list[i].banks[0].fullName;
            list[i].bankAccount = list[i].banks[0].number;
            list[i].bankName = list[i].banks[0].branchName;
            list[i].branchName = list[i].banks[0].branchName;
            list[i].province = list[i].banks[0].province;
            list[i].city = list[i].banks[0].city;
            list[i].bankmobile = list[i].banks[0].mobile;
          }
          if (list[i].score) {
            list[i].effctiveScore = list[i].score.effctiveScore;
            list[i].noeffctiveScore = list[i].score.noeffctiveScore;
            list[i].sumScore = list[i].score.sumScore;
          }
        }
        const data = this.formatJson(filterVal, list);
        export_json_to_excel(tHeader, data, '客户列表excel');
      })
    },
    formatJson: function (filterVal, jsonData) {
      return jsonData.map(v => filterVal.map(j => v[j]))
    },
    //审批权限
    ApproveUser(index,row) {
      var approveAuth = row.approveAuth;
      var userArr = this.user.approve;
      return commons.ApproveUser(approveAuth,userArr);
    },
    configUser: function () {
      var userArr = this.user.configAuth;
      return !commons.contains(userArr, '1');
    },
    //显示批量开户界面
    batchaccount: function () {
      this.matchFormVisible = true;
      if (this.$refs['matchForm'] !== undefined) {
        this.$refs['matchForm'].resetFields();
      }
      // this.$refs['matchForm'].resetFields();
      this.matchForm = {
        productids: ''
      };
    },
    matchSubmit: function () {
      this.$refs.matchForm.validate((valid) => {
        if (valid) {
          this.$confirm('确认提交吗？', '提示', {}).then(() => {
            this.matchLoading = true;
            let para = new FormData();
            para.append('code', 'test_test');
            para.append('productids', this.matchForm.productids);
            createUsers(para).then((res) => {
              if (res.data.state == 0) {
                this.$message({
                  message: res.data.result.msg,
                  type: 'success'
                });
                this.matchFormVisible = false;
                if (this.$refs['matchForm'] !== undefined) {
                  this.$refs['matchForm'].resetFields();
                }
                // this.$refs['matchForm'].resetFields();
              }
              else {
                this.$message({
                  message: res.data.result,
                  type: 'error'
                });
              }
              this.matchLoading = false;

            }).catch(() => {
              this.matchLoading = false;
            });
          });
        }
      });
    },
    //显示新增界面
    handleAdd: function () {
      this.addFormVisible = true;
      if (this.$refs['addForm'] !== undefined) {
        this.$refs['addForm'].resetFields();
      }
      // this.$refs['addForm'].resetFields();
      this.addForm = {
        userName: '',
        nickName: '',
        mobile: '',
        email: '',
        agrementNo: '',
        channelName: '',
        channelCode: '',
        saleName: '',
        saleCode: '',
        // userCode: '',
        newPassword: '',
        level: '',
        wxOpenId: '',
        registeDate: '',
        lastloginDate: '',
        shippingAddress: '',
        address: '',
        state: '1',
        branchCode: '',
        headUrl: '',
        storeFlag: '1',
        userType: '2',
        agrementName: '',
        applyAgrNoType: '',
        areaCode: '',
        areaName: '',
        idNumber: '',
        introduceId: '',
        loginState: '',
        loginTimes: '0',
        loginTimesContinuity: '0',
        points: '0',
        popularity: '0',
        refereePro: '',
        refereeId: '',
        shopIntroduct: '',
        shopName: '',
        storeCreateTime: '',
        typeState: '1',
        userCodeBs: '',
        wxCity: '',
        wxCountry: '',
        wxGroupid: '',
        wxLanguage: '',
        wxProvince: '',
        wxRemark: '',
        wxSex: '1',
        wxSubscribe: '',
        wxSubscribeTime: '',
        wxTagidList: '',
        channelType: '',
        comCode: '',
        configSerialNo: '',
        idType: '1',
        baseRate: ''
      };
    },
    addSubmit: function () {
      this.$refs.addForm.validate((valid) => {
        if (valid) {
          this.$confirm('确认提交吗？', '提示', {}).then(() => {
            this.addLoading = true;
            let para = Object.assign({}, this.addForm);
            addUser(para).then((res) => {
              if (res.data.success) {
                this.$message({
                  message: '提交成功',
                  type: 'success'
                });
                if (this.$refs['addForm'] !== undefined) {
                  this.$refs['addForm'].resetFields();
                }
                // this.$refs['addForm'].resetFields();
                this.addFormVisible = false;
                this.getcustoms(true);
                this.sels = [];
              }
              else {
                this.$message({
                  message: res.data.result,
                  type: 'error'
                });
              }
              this.addLoading = false;

            }).catch(() => {
              this.addLoading = false;
            });
          });
        }
        else {
          this.$message({
            message: '请填写必填项',
            type: 'warning'
          });
        }
      });
    },
    //显示修改界面
    handleEdit: function (index, row) {
      this.editFormVisible = true;
      this.editForm = Object.assign({}, row);
      if (this.editForm.configSerialNo) {
        this.editForm.configSerialNo = this.editForm.configSerialNo.toString();
      }
      if (row.registerType == '1') {
        this.isChannelUser=true;
      }
    },
    // 是否显示修改按钮
    showEidtbtn: function (index, row) {
      if (this.customUpdate) {
        return row.approve ? false : true;
      } else {
        return false;
      }
    },
    // 是否显示审批按钮
    showApprove: function (index, row) {
      if (this.customApprove = true) {
        return row.approve ? true : false;
      } else {
        return false;
      }
    },
    // 显示审批佣金界面
    handleApprove: function (index, row, type) {
      this.approveRateFormVisible = true;
      this.theApproveType = type;
      this.shopRateUser = row.userName;
      this.approveRatedata = JSON.parse(row.approve.content);
      this.approveUserCode = row.userCode;
    },

    // 显示审批业务关系代码佣金界面
    handleApproveBus: function (index, row, type) {
      this.approveRateFormVisible = true;
      this.theApproveType = type;
      let newArr = [];
      let thisData = JSON.parse(row.content);
      $.each(thisData, function (i, j) {
        newArr.push(thisData[i]);
      });
      this.approveRatedata = newArr;
      this.shopRateUser = newArr[0].agreementNo;

      this.approveUserCode = newArr[0].agreementNo;
    },

    // 同意审批
    agreeApprove: function (type, num) {
      this.$confirm('确认提交吗？', '提示', {}).then(() => {
        this.detailLoading = true;
        let para = new FormData();
        para.append("id", this.approveUserCode);
        para.append("approveType", num);
        para.append("type", type);
        para.append("remark", "");
        approveActivity(para).then((res) => {
          if (res.data.success) {
            this.$message({
              message: '提交成功',
              type: 'success'
            });
            this.approveRateFormVisible = false;
            if (num == 9) {
              this.GetApproveBusiness();
            } else {
              this.getcustoms(true);
            }
          }
          else {
            this.$message({
              message: res.data.result,
              type: 'error'
            });
            this.approveRateFormVisible = false;
          }
          this.detailLoading = false;
        }).catch(() => {
          this.detailLoading = false;
        });
      });
    },

    //显示佣金比例界面
    handleshopRate: function (index, row) {
      this.shopRateFormVisible = true;
      this.userrow = row;
      this.GetshopRate();
      this.shopRateUser = row.userName;
    },

    //显示审批代码佣金界面
    approveBusiness: function (index, row) {
      this.approveBusinessFormVisible = true;
      this.GetApproveBusiness();
    },

    //显示代码佣金明细界面
    particularsBusiness: function (index, row) {
      this.particularsFormVisible = true;
      this.particulars.agrementNo = '';
      this.GetParticularsBusiness();
    },

    //查询用户佣金比例
    GetshopRate: function () {
      let para = new FormData();
      para.append("pageSize", this.shopRatepageSize);
      para.append("pageNumber", this.shopRatepage);
      para.append("userCode", this.userrow.userCode);
      this.shopRateLoading = true;
      shopRate(para).then((res) => {
        if (res.data.success) {
          this.shopRateLoading = false;
          this.shopRatetotal = res.data.result.totalElements;
          this.shopRatedata = res.data.result.content;
        }
        else {
          this.shopRateLoading = false;
        }
      }).catch(() => {
        this.shopRateLoading = false;
      });
    },

    //查询审批代码佣金
    GetApproveBusiness: function () {
      let para = new FormData();
      para.append("pageSize", this.approveBusinesspageSize);
      para.append("pageNumber", this.approveBusinesspage);
      para.append("approveType", '9');
      this.approveBusinessLoading = true;
      waitAapprove(para).then((res) => {
        if (res.data.success) {
          this.approveBusinessLoading = false;
          this.approveBusinesstotal = res.data.result.totalElements;
          this.approveBusinessdata = res.data.result.content;
        }
        else {
          this.approveBusinessLoading = false;
        }
      }).catch(() => {
        this.approveBusinessLoading = false;
      });
    },

    //查询审批代码佣金详情-------
    GetApproveDetail: function () {
      let para = new FormData();
      para.append("pageSize", this.approveDetailpageSize);
      para.append("pageNumber", this.approveDetailpage);
      para.append("approveType", '9');
      this.approveDetailLoading = true;
      waitAapprove(para).then((res) => {
        if (res.data.success) {
          this.approveDetailLoading = false;
          // this.approveDetailtotal = res.data.result.totalElements;
          // this.approveDetaildata = res.data.result.content;
          let newArr = [];
          let d = res.data.result.content;
          let thisData;
          $.each(d, function (i, j) {
            thisData = JSON.parse(j.content);
            for (var k = 0; k < thisData.length; k++) {
              newArr.push(thisData[k]);
            }
          });
          this.approveDetailtotal = thisData.length;
          this.approveDetaildata = newArr;
        }
        else {
          this.approveDetailLoading = false;
        }
      }).catch(() => {
        this.approveDetailLoading = false;
      });
    },

    //查询代码佣金明细
    GetParticularsBusiness: function () {
      let para = new FormData();
      para.append("pageSize", this.particularspageSize);
      para.append("pageNumber", this.particularspage);
      para.append("agrementNo", this.particulars.agrementNo);
      this.particularsLoading = true;
      agreeRate(para).then((res) => {
        if (res.data.success) {
          this.particularsLoading = false;
          this.particularstotal = res.data.result.totalElements;
          this.particularsdata = res.data.result.content;
        }
        else {
          this.particularsLoading = false;
        }
      }).catch(() => {
        this.particularsLoading = false;
      });
    },

    RateDel: function (index, row) {
      this.shopRateLoading = true;
      let para = new FormData();
      para.append("id", row.id);
      deleteShopRate(para).then((res) => {
        this.shopRateLoading = false;
        //NProgress.done();
        this.$message({
          message: '删除成功',
          type: 'success'
        });
        this.GetshopRate();
      }).catch(() => {
        this.shopRateLoading = false;
      });
    },

    //删除代码佣金明细
    particularsDel: function (index, row) {
      this.$confirm('确认删除吗？', '提示', {}).then(() => {
        this.particularsLoading = true;
        let para = new FormData();
        para.append("id", row.id);
        deleteAgreeRate(para).then((res) => {
          this.particularsLoading = false;
          //NProgress.done();
          this.$message({
            message: '删除成功',
            type: 'success'
          });
          this.GetParticularsBusiness();
        }).catch(() => {
          this.particularsLoading = false;
        });
      });
    },

    //修改
    editSubmit: function () {
      this.$refs.editForm.validate((valid) => {
        if (valid) {
          this.$confirm('确认提交吗？', '提示', {}).then(() => {
            this.editLoading = true;
            let para = Object.assign({}, this.editForm);
            updateUser(para).then((res) => {
              this.editLoading = false;
              if (res.data.success) {
                this.$message({
                  message: '提交成功',
                  type: 'success'
                });
                if (this.$refs['editForm'] !== undefined) {
                  this.$refs['editForm'].resetFields();
                }
                // this.$refs['editForm'].resetFields();
                this.editFormVisible = false;
                this.getcustoms(true);
              }
              else {
                this.$message({
                  message: res.data.result,
                  type: 'error'
                });
              }
            }).catch(() => {
              this.editLoading = false;
            });
          });
        }
      });
    },

    selsChange: function (sels) {
    },
    selectTure: function (sels, s) {
      var temp1 = false;
      var temp2 = false;
      if (this.sels.length > 0) {
        temp2 = sels.find(d => d.id == s.id);
        for (var i in this.sels) {
          if (this.sels[i].id == s.id) {
            temp1 = true;
          }
        }
        if (temp2 && !temp1) {
          this.sels.push(s);
        }
        else if (!temp2 && temp1) {
          this.sels.splice(this.sels.findIndex(item => item.id == s.id), 1);
        }
        // if(!temp1){
        //   this.sels.push(s);
        // }
      }
      else {
        this.sels = sels;
      }

      if (sels.length <= 0) {
        this.sels = [];
      }
    },
    selsAll: function (sels) {

      if (this.sels.length <= 0) {
        this.sels = sels;
      }
      else {
        for (var i in sels) {
          if (this.sels.find(d => d.id == sels[i].id))
            continue;
          else
            this.sels.push(sels[i]);
        }
      }
    },
    commissionselsChange: function (sels, s) {
      var temp1 = false;
      var temp2 = false;
      if (this.commissionsels.length > 0) {
        temp2 = sels.find(d => d.id == s.id);
        for (var i in this.commissionsels) {
          if (this.commissionsels[i].id == s.id) {
            temp1 = true;
          }
        }
        if (temp2 && !temp1) {
          this.commissionsels.push(s);
        }
        else if (!temp2 && temp1) {
          this.commissionsels.splice(this.commissionsels.findIndex(item => item.id == s.id), 1);
        }
      }
      else {
        this.commissionsels = sels;
      }

      if (sels.length <= 0) {
        this.commissionsels = [];
      }
    },
    commissionselsAll: function (sels) {
      if (this.commissionsels.length <= 0) {
        this.commissionsels = sels;
      }
      else {
        for (var i in sels) {
          if (this.commissionsels.find(d => d.id == sels[i].id))
            continue;
          else
            this.commissionsels.push(sels[i]);
        }
      }
    },
    //配置佣金
    commission: function () {
      if (this.sels.length == 0) {
        this.$message({
          message: '至少选择一个客户',
          type: 'error'
        });
      }
      else {
        this.selectionNames = this.sels.map(item => item.userName).toString();
        this.commissionFormVisible = true;
        this.Getproducts();
      }
    },


    //配置业务关系代码佣金
    businessselsChange: function (sels, s) {
      var temp1 = false;
      var temp2 = false;
      if (this.businesssels.length > 0) {
        temp2 = sels.find(d => d.id == s.id);
        for (var i in this.businesssels) {
          if (this.businesssels[i].id == s.id) {
            temp1 = true;
          }
        }
        if (temp2 && !temp1) {
          this.businesssels.push(s);
        }
        else if (!temp2 && temp1) {
          this.businesssels.splice(this.businesssels.findIndex(item => item.id == s.id), 1);
        }
      }
      else {
        this.businesssels = sels;
      }
      if (sels.length <= 0) {
        this.businesssels = [];
      }
    },
    businessselsAll: function (sels) {
      if (this.businesssels.length <= 0) {
        this.businesssels = sels;
      }
      else {
        for (var i in sels) {
          if (this.businesssels.find(d => d.id == sels[i].id))
            continue;
          else
            this.businesssels.push(sels[i]);
        }
      }
    },
    business: function () {
      this.businessFormVisible = true;//显示业务关系代码佣金界面
      this.agreementNoForm.agreementNo = '';
      this.businessGetproducts();
    },
    //业务关系代码佣金界面获取产品列表
    businessGetproducts: function () {
      this.businessdata = [];
      let productlist = [];
      //传参
      let para = new FormData();
      para.append("pageSize", this.businesspageSize);
      para.append("pageNumber", this.businesspage);
      para.append("status", 'true');
      this.businessdataLoading = true;//加载动画
      //调用产品列表接口
      getUserListPage(para).then((res) => {
        if (res.data.success) {
          this.businessdataLoading = false;//关闭加载动画
          this.businesstotal = res.data.result.totalElements;
          for (var s = 0; s < Math.ceil(res.data.result.totalElements / 10.0); s++) {
            this.IsValidate.push([]);
            for (var p = 0; p < 10; p++) {
              this.IsValidate[s].push(false);
            }
          }
          productlist = res.data.result.content;
          for (var i in productlist) {
            this.businessdata.push({
              id: productlist[i].id,
              productname: productlist[i].productCname,
              productEname: productlist[i].productEname,
              rate: 0
            });
            for (var k in this.rateData) {
              if (productlist[i].id == this.rateData[k].id) {
                this.businessdata[i].rate = this.rateData[k].rate;
              }
            }
          }
          this.$refs.producttable.clearSelection();
          if (this.businesssels) {
            for (var k in this.businesssels) {
              for (var i in this.businessdata) {
                if (this.businessdata[i].id == this.businesssels[k].id) {
                  this.$refs.producttable.toggleRowSelection(this.businessdata[i], true);
                }
              }
            }
          }
        }
        else {
          this.businessdataLoading = false;
        }
      }).catch(() => {
        this.businessdataLoading = false;
      });
    },


    //加载产品列表
    Getproducts: function () {
      this.commissiondata = [];
      let productlist = [];
      let para = new FormData();
      para.append("pageSize", this.commissionpageSize);
      para.append("pageNumber", this.commissionpage);
      para.append("status", 'true');
      this.commissiondataLoading = true;
      getUserListPage(para).then((res) => {
        if (res.data.success) {
          this.commissiondataLoading = false;
          this.commissiontotal = res.data.result.totalElements;
          for (var s = 0; s < Math.ceil(res.data.result.totalElements / 10.0); s++) {
            this.IsValidate.push([]);
            for (var p = 0; p < 10; p++) {
              this.IsValidate[s].push(false);
            }
          }
          productlist = res.data.result.content;
          for (var i in productlist) {
            this.commissiondata.push({
              id: productlist[i].id,
              productname: productlist[i].productCname,
              productEname: productlist[i].productEname,
              rate: 0
            });
            for (var k in this.rateData) {
              if (productlist[i].id == this.rateData[k].id) {
                this.commissiondata[i].rate = this.rateData[k].rate;
              }
            }
          }
          this.$refs.producttable.clearSelection();
          if (this.commissionsels) {
            // this.sels.forEach(item => {
            // this.$refs.table.toggleRowSelection(this.customs.find(d => d.id == item.id));
            // this.sels.pop();
            for (var k in this.commissionsels) {
              for (var i in this.commissiondata) {
                if (this.commissiondata[i].id == this.commissionsels[k].id) {
                  this.$refs.producttable.toggleRowSelection(this.commissiondata[i], true);
                }
              }
            }
            // });
          }
        }
        else {
          this.commissiondataLoading = false;
        }
      }).catch(() => {
        this.commissiondataLoading = false;
      });
    },
    //双击编辑
    dblclick(row, column, cell, event) {
      if (column.label == '比例(可双击修改)') {
        this.InpitId = row.id;
        this.InputStatus = true;
        this.$nextTick(function () {
          $(event.target).children().find("input").focus();
        })
      }
      else {
        this.InputStatus = false;
        if (row.rate != 0) {
          this.rateData.forEach(function (d, index) {
            if (d.id == row.id) {
              d.rate = row.rate;
            }
          });
          if (!this.rateData.find(d => d.id == row.id)) {
            this.rateData.push({
              page: this.commissionpage,
              id: row.id,
              rate: row.rate
            });
          }
        }
      }
    },
    helpValidate: function (value, index) {
      if (!( /^-?\d+(\.\d{1,6})?$/.test(value)) || value > 1) {
        this.IsValidate[this.commissionpage - 1][index] = true;
        return true;
      }
      else {
        this.IsValidate[this.commissionpage - 1][index] = false;
        return false;
      }
    },
    helptext: function (value) {
      if (value == null || value == " " && !value == '0' || value.length == 0) {
        return '比例不能为空';
      }
      else if (!(/^-?\d+(\.\d{1,6})?$/.test(value))) {
        return '小数不能超过6位';
      }
      else if (value > 1) {
        return '比例不能大于1';
      }
      else {
        return '';
      }
    },
    //是否显示比例input
    Isinput: function (id, bool, status) {
      return this.InpitId == id && bool ? (status ? true : false) : (status ? false : true);
    },
    commissionSubmit: function () {
      var para = {
        userCodes: this.sels.map(item => item.userCode).toString(),
        storeConfig: []
      };
      for (var i in this.commissionsels) {
        para.storeConfig.push({
          productName: this.commissionsels[i].productname,
          productId: parseInt(this.commissionsels[i].id),
          rate: this.commissionsels[i].rate
        });
      }
      if (commons.ifArrVal(this.IsValidate, true) == 1) {
        this.$message({
          message: '积分比例配置格式不正确!',
          type: 'warning'
        });
      }
      else {
        this.$confirm('确认提交吗？', '提示', {}).then(() => {
          this.commissionLoading = true;
          setShopRate(para).then((res) => {
            if (res.data.success) {
              this.$message({
                message: '提交成功',
                type: 'success'
              });
              this.commissionFormVisible = false;
              this.sels = [];
              this.commissiondata = [];
              this.commissionsels = [];
              this.rateData = [];
              this.getcustoms(true);
            }
            else {
              this.$message({
                message: res.data.result,
                type: 'error'
              });
            }
            this.commissionLoading = false;
          }).catch(() => {
            this.commissionLoading = false;
          });
        });
      }
    },


    //配置业务关系代码佣金提交
    businessSubmit: function () {
      //传参
      var para = {
        userCodes: this.agreementNoForm.agreementNo,
        storeConfig: []
      };
      for (var i in this.businesssels) {
        para.storeConfig.push({
          productName: this.businesssels[i].productname,
          productId: parseInt(this.businesssels[i].id),
          rate: this.businesssels[i].rate
        });
      }
      if (commons.ifArrVal(this.IsValidate, true) == 1) {
        this.$message({
          message: '积分比例配置格式不正确!',
          type: 'warning'
        });
      }
      else {
        this.$confirm('确认提交吗？', '提示', {}).then(() => {
          this.businessLoading = true;
          setShopRate(para).then((res) => {
            if (res.data.success) {
              this.$message({
                message: '提交成功',
                type: 'success'
              });
              this.businessFormVisible = false;
              this.sels = [];
              this.businessdata = [];
              this.businesssels = [];
              this.rateData = [];
              this.getcustoms(true);
            }
            else {
              this.$message({
                message: res.data.result,
                type: 'error'
              });
            }
            this.businessLoading = false;
          }).catch(() => {
            this.businessLoading = false;
          });
        });
      }
    },


    //input失去焦点
    inputblur: function (row) {
      this.InputStatus = false;
      if (row.rate != 0) {
        this.rateData.forEach(function (d, index) {
          if (d.id == row.id) {
            d.rate = row.rate;
          }
        });
        if (!this.rateData.find(d => d.id == row.id)) {
          this.rateData.push({
            page: this.commissionpage,
            id: row.id,
            rate: row.rate
          });
        }
      }
    },
    // commissionSubmit: function () {
    //   var para = {
    //     userCodes: this.sels.map(item => item.userCode).toString(),
    //     storeConfig: []
    //   };
    //   for (var i in this.commissionsels) {
    //     para.storeConfig.push({
    //       productId: parseInt(this.commissionsels[i].id),
    //       rate: parseInt(this.commissionsels[i].rate)
    //     });
    //   }

    //   if (commons.ifArrVal(this.IsValidate, true) == 1) {
    //     this.$message({
    //       message: '积分比例配置格式不正确!',
    //       type: 'warning'
    //     });
    //   }
    //   else {
    //     this.$confirm('确认提交吗？', '提示', {}).then(() => {
    //       this.commissionLoading = true;
    //       setShopRate(para).then((res) => {
    //         if (res.data.success) {
    //           this.$message({
    //             message: '提交成功',
    //             type: 'success'
    //           });
    //           this.commissionFormVisible = false;
    //           this.sels = [];
    //           this.commissiondata = [];
    //           this.commissionsels = [];
    //           this.rateData = [];
    //           this.getcustoms(true);
    //         }
    //         else {
    //           this.$message({
    //             message: res.data.result,
    //             type: 'error'
    //           });
    //         }
    //         this.commissionLoading = false;
    //       }).catch(() => {
    //         this.commissionLoading = false;
    //       });
    //     });
    //   }

    // },
    //详情
    handleDetail: function (index, row) {
      this.detailForm = Object.assign({}, row);
      if (this.detailForm.configSerialNo) {
        this.detailForm.configSerialNo = this.detailForm.configSerialNo.toString();
      }
      this.rowID = row.id;
      this.detailFormVisible = true;
      this.detailForm.state = row.state == "0" ? "已注销" : (row.state == "1" ? "有效" : "挂失");
      this.detailForm.storeFlag = row.storeFlag == "1" ? "是" : "否";
      this.detailForm.userType = commons.customType(row.userType);
      if (row.refereeUser) {
        this.detailForm.refereeId = row.refereeUser.id;
      }
    },

    //审批代码佣金详情
    handleApproveDetail: function (index, row) {
      this.approveDetailFormVisible = true;
      let newArr = [];
      let thisData = JSON.parse(row.content);
      $.each(thisData, function (i, j) {
        newArr.push(thisData[i]);
      });
      this.approveDetailtotal = thisData.length;
      this.approveDetaildata = newArr;
      // this.GetApproveDetail();
    },
    //批量删除
    // batchRemove: function () {
    //   var ids = this.sels.map(item => item.id).toString();
    //   this.$confirm('确认删除选中记录吗？', '提示', {
    //     type: 'warning'
    //   }).then(() => {
    //     this.listLoading = true;
    //     let para = new FormData();
    //     para.append("ids", ids);
    //     removeAd(para).then((res) => {
    //       this.listLoading = false;
    //       this.$message({
    //         message: '删除成功',
    //         type: 'success'
    //       });
    //       this.getcustoms(true);
    //     });
    //   }).catch(() => {

    //   });
    // }

    btnShow: function () {
      let thisData = JSON.parse(sessionStorage.getItem('154'));
      let _this = this;
      $.each(thisData, function (i, j) {
        if (thisData[i] == "agreeBrokerage") {
          _this.agreeBrokerage = true;
        }
        if (thisData[i] == "agreeBrokerageDetail") {
          _this.agreeBrokerageDetail = true;
        }
        if (thisData[i] == "approveAgreeBrokerage") {
          _this.approveAgreeBrokerage = true;
        }
        if (thisData[i] == "customAdd") {
          _this.customAdd = true;
        }
        if (thisData[i] == "customApprove") {
          _this.customApprove = true;
        }
        if (thisData[i] == "customBatchAdd") {
          _this.customBatchAdd = true;
        }
        if (thisData[i] == "customBrokerage") {
          _this.customBrokerage = true;
        }
        if (thisData[i] == "customDetail") {
          _this.customDetail = true;
        }
        if (thisData[i] == "customExport") {
          _this.customExport = true;
        }
        if (thisData[i] == "customQuery") {
          _this.customQuery = true;
        }
        if (thisData[i] == "customSend") {
          _this.customSend = true;
        }
        if (thisData[i] == "customUpdate") {
          _this.customUpdate = true;
        }
        if (thisData[i] == "setCustomBrokerage") {
          _this.setCustomBrokerage = true;
        }
      });
    }
  },
  mounted() {
    this.btnShow();
    this.getcustoms(true);
  }
}

</script>

<style scoped>
.help-block {
  color: #ff4949;
  font-size: 12px;
  display: block;
}
</style>